procedure TPlayScene.DrawMiniMap(Surface: TDXTexture); //ͼ
var
  D, dd                     : TDXTexture;
  v                         : Boolean;
  mx, my, nX, nY, i         : Integer;
  Actor                     : TActor;
  X, Y                      : Integer;
  btColor                   : byte;
  rx, ry, rrx, rry          : Real;
  S                         : string;
  tMapPath                  : array of TPoint;
  pMapDescInfo              : pTMapDescInfo;
  PenColor                  :TColor;
begin
  if g_nMiniMapIndex < 0 then Exit;
  if g_nMiniMapIndex >= 300 then begin
    D := g_WMiniMapImages.Images[Format(g_sMiniMap, [g_nMiniMapIndex + 1])];
  end else
    D := g_WMMapImages.Images[g_nMiniMapIndex];
  if D = nil then begin
    g_DrawingMiniMap := False;
    Exit;
  end;
  if g_nViewMinMapLv = 1 then begin
    mx := (g_MySelf.m_nCurrX * 48) div 32;
    my := g_MySelf.m_nCurrY;
    g_MiniMapRC.Left := _MAX(0, mx - 60);
    g_MiniMapRC.Top := _MAX(0, my - 60);
    g_MiniMapRC.Right := _MIN(D.ClientRect.Right, g_MiniMapRC.Left + 120);
    g_MiniMapRC.Bottom := _MIN(D.ClientRect.Bottom, g_MiniMapRC.Top + 120);

    if g_DrawMiniBlend then begin
      DrawBlendEx(Surface, (SCREENWIDTH - 120), 0, g_MiniMapRC, D, 150);
    end else begin
      Surface.Draw(SCREENWIDTH - 120, 0, g_MiniMapRC, D, False);
    end;

    g_DrawingMiniMap := True;

    if GetTickCount > m_dwBlinkTime + 300 then begin
      m_dwBlinkTime := GetTickCount;
      m_boViewBlink := not m_boViewBlink;
    end;
    if m_boViewBlink then begin
      mx := (SCREENWIDTH - 120) + (g_MySelf.m_nCurrX * 48) div 32 - g_MiniMapRC.Left;
      my := (g_MySelf.m_nCurrY * 32) div 32 - g_MiniMapRC.Top;
      g_DXCanvas.FillRectAlpha(Rect(mx - 1, my - 1, mx + 2, my + 2), GetRGB(255), 255);
    end;

    for i := 0 to m_ActorList.Count - 1 do begin //opt
      Actor := TActor(m_ActorList[i]);
      if (Actor <> nil) and not Actor.m_boDeath and Actor.m_boVisible and Actor.m_boHoldPlace and (Actor <> g_MySelf) then begin
        if (abs(Actor.m_nCurrX - g_MySelf.m_nCurrX) <= 10) and (abs(Actor.m_nCurrY - g_MySelf.m_nCurrY) <= 10) then begin
          mx := (SCREENWIDTH - 120) + (Actor.m_nCurrX * 48) div 32 - g_MiniMapRC.Left;
          my := Actor.m_nCurrY - g_MiniMapRC.Top;
          case Actor.m_btRace of
            12, 24, 50: btColor := 250;
            54, 55, 81: btColor := 0;
            0: begin
                if Actor.m_btNameColor = 255 then
                  btColor := 251
                else
                  btColor := Actor.m_btNameColor;
              end;
          else
            btColor := 249;
          end;
          if Actor.m_btNameColor = 253 then btColor := 253;
          g_DXCanvas.FillRectAlpha(Rect(mx - 1, my - 1, mx + 2, my + 2), GetRGB(btColor),255);
        end;
      end;
    end;

    for i := 0 to g_xCurMapDescList.Count - 1 do begin
      pMapDescInfo := pTMapDescInfo(g_xCurMapDescList.Objects[i]);
      mx := (SCREENWIDTH - 120) + (pMapDescInfo.nPointX * 48) div 32 - g_MiniMapRC.Left;
      my := pMapDescInfo.nPointY - g_MiniMapRC.Top;
      if (mx >= SCREENWIDTH - 120) and ((my >= 0) and (my <= 120)) then begin
        if g_DrawMiniBlend then
          g_DXCanvas.BoldTextOut( mx, my, pMapDescInfo.nColor,pMapDescInfo.szPlaceName)
        else
          g_DXCanvas.BoldTextOut( mx, my, pMapDescInfo.nColor, pMapDescInfo.szPlaceName);
      end;
    end;
    if g_ShowMiniMapXY then begin
      rx := g_MySelf.m_nCurrX + (g_nMouseX - (SCREENWIDTH - (g_MiniMapRC.Right - g_MiniMapRC.Left)) - ((g_MiniMapRC.Right - g_MiniMapRC.Left) div 2)) * 2 / 3;
      ry := g_MySelf.m_nCurrY + (g_nMouseY - (g_MiniMapRC.Bottom - g_MiniMapRC.Top) div 2);
      if (rx >= 0) and (ry >= 0) then begin
        S := Format('%s:%s', [IntToStr(Round(rx)), IntToStr(Round(ry))]);

        with g_DXCanvas do begin  //
        TextOut(SCREENWIDTH - TextWidth(S) - 02, g_MiniMapRC.Bottom - g_MiniMapRC.Top - 14,clWhite, IntToStr(Round(rx)) + ':' + IntToStr(Round(ry)));
        end;
      end;
    end;

    if g_MapPath <> nil then  //ԶѰ·ʱѡĶλ  Development 2019-01-11
    if g_MoveStep <= High(g_MapPath) then
    for i := g_MoveStep to High(g_MapPath) do
    begin
      mx := (SCREENWIDTH - 120) + (g_MapPath[i].X * 48) div 32 - g_MiniMapRC.Left;
      my := g_MapPath[i].Y - g_MiniMapRC.Top;
      if (mx >= SCREENWIDTH - 120) and ((my >= 0) and (my <= 120)) then
      g_DXCanvas.FillRectAlpha(Rect(mx, my, mx + 2, my + 2), GetRGB(224), 255); //ɫ
    end;

  end else begin
    g_MiniMapRC.Left := SCREENWIDTH - MINIMAPSIZE;
    g_MiniMapRC.Top := 0;
    g_MiniMapRC.Right := SCREENWIDTH;
    g_MiniMapRC.Bottom := MINIMAPSIZE;

    if g_DrawMiniBlend then begin
      g_DsMiniMapPixel.StretchDraw(g_MapRect, D.ClientRect, D, False);
      DrawBlendStretchEX(Surface, Bounds(SCREENWIDTH-200, 0, 200, 200), D.ClientRect, D, 150);
    end else
      Surface.StretchDraw(g_MiniMapRC, D.ClientRect, D, False);

    g_DrawingMiniMap := True;
    if GetTickCount > m_dwBlinkTime + 300 then begin
      m_dwBlinkTime := GetTickCount;
      m_boViewBlink := not m_boViewBlink;
    end;
    rx := D.Width / (MINIMAPSIZE * 1.5);
    ry := D.Height / MINIMAPSIZE;
    rrx := rx;
    rry := ry;
    if m_boViewBlink then begin
      mx := g_MiniMapRC.Left + Round(g_MySelf.m_nCurrX / rx);
      my := Round(g_MySelf.m_nCurrY / ry);
      g_DXCanvas.FillRectAlpha(Rect(mx - 1, my - 1, mx + 2, my + 2), GetRGB(255),255);
    end;

    if g_boOpenAutoPlay and (g_APMapPath <> nil) then begin
      nX := Round(12 / rx);
      nY := Round(12 / ry);
      SetLength(tMapPath, High(g_APMapPath) + 1);
      for i := 0 to High(g_APMapPath) do begin
        mx := Round(g_APMapPath[i].X / rx);
        my := Round(g_APMapPath[i].Y / ry);
        tMapPath[i] := Point(SCREENWIDTH - MINIMAPSIZE + mx, my);
        g_DXCanvas.FillRectAlpha(Rect(SCREENWIDTH - 200 + mx - 1, my - 1, SCREENWIDTH - 200 + mx + 1, my + 1), GetRGB(249),255);

        with g_DXCanvas do begin
          if i = g_APStep then
            PenColor := clRed
          else
            PenColor := clLime;

          RoundRect((SCREENWIDTH - 200 + mx + nX), (0 + my + nY), (SCREENWIDTH - 200 + mx - nX), (0 + my - nY), nX * 2, nY * 2,PenColor);
        end;
      end;

      with g_DXCanvas do begin
        PenColor := GetRGB(151);
        Polygon(tMapPath,PenColor,True);
      end;

    end;

    if g_MapPath <> nil then begin
      if g_MoveStep <= High(g_MapPath) then
        for i := g_MoveStep to High(g_MapPath) do begin
          mx := SCREENWIDTH - 200 + Round(g_MapPath[i].X / rx);
          my := Round(g_MapPath[i].Y / ry);

          g_DXCanvas.FillRectAlpha(Rect(mx, my, mx + 1, my + 1), GetRGB(224),255);
        end;
    end;

   with g_DXCanvas do begin
    for i := 0 to g_xCurMapDescList.Count - 1 do begin
      pMapDescInfo := pTMapDescInfo(g_xCurMapDescList.Objects[i]);
      mx := SCREENWIDTH - 200 + Round(pMapDescInfo.nPointX / rrx);
      my := Round(pMapDescInfo.nPointY / rry);
      if g_DrawMiniBlend then
        BoldTextOut( mx, my, pMapDescInfo.nColor, pMapDescInfo.szPlaceName)
      else
        BoldTextOut( mx, my, pMapDescInfo.nColor, pMapDescInfo.szPlaceName);
    end;
    if g_ShowMiniMapXY then begin
      rx := (g_nMouseX - g_MiniMapRC.Left) * (Map.m_MapHeader.wWidth / MINIMAPSIZE);
      ry := g_nMouseY * (Map.m_MapHeader.wHeight / MINIMAPSIZE);
      if (rx >= 0) and (ry >= 0) then begin
        S := Format('%s:%s', [IntToStr(Round(rx)), IntToStr(Round(ry))]);
            TextOut(SCREENWIDTH - TextWidth(S) - 2, MINIMAPSIZE - 14, S,clWhite);
      end;
    end;
   end;
  end;
end;